import * as types from '../mutation-types'

// initial state
const state = {
	ishttp:false,
	menu:'',
	menuCrumbs:[],
  token: '',
  menus:[]
}

// getters
const getters = {
  getType: state => state.ishttp,
  getToken: state => state.token,
  getMenuCrumbs: state => state.menuCrumbs,
  getMenu: state => state.menu,
  getMenus: state => state.menus
}


// mutations
const mutations = {
  [types.LOGIN_IN] (state,arr) {
    state.token = arr[0]
    state.menu = arr[1]
    state.menuCrumbs = arr[2]
  },
  [types.LOGIN_OUT] (state) {
    state.token = ''
    state.menu = ''
    state.menuCrumbs = ''
  },
  [types.SET_MENU] (state,arr) {
    state.menus = arr
  },
  [types.REQUEST_ING] (state) {
    state.ishttp = true
  },
  [types.REQUEST_END] (state) {
    state.ishttp = false
  }
}

export default {
  state,
  getters,
  mutations
}
